package com.easipass.framework.eirframeworkjdbc;

import com.easipass.framework.eirframeworkjdbc.model.Service;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;
import org.springframework.stereotype.Repository;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

@Repository
@Transactional
public interface ServiceRepository extends JpaRepository<Service, Long> {
    List<Service> findAllByName(String name);

    @Query(value = "select s from Service s where s.process like :appName%")
    List<Service> findByProcessLike(@Param("appName") String source);

    Service findByName(String name);

    @Modifying
    @Query("update Service set process=?1,uinfo=?2 where id=?3")
    int updateServiceById(String process,String uinfo, Long id);
}
